<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
	<title></title>
	<meta name="generator" content="LibreOffice 25.8.1.1 (Windows)"/>
	<meta name="author" content="hao"/>
	<meta name="created" content="2025-04-02T01:40:11"/>
	<meta name="changedby" content="星辰"/>
	<meta name="changed" content="2025-04-02T01:42:00"/>
	<meta name="ICV" content="D95EA90491A943788C6F77FC2E76A295_12"/>
	<meta name="KSOProductBuildVer" content="2052-12.1.0.20305"/>
	<meta name="KSOTemplateDocerSaveRecord" content="eyJoZGlkIjoiM2VmNDY4ZDNlMDMxMDExYTU2OTkxZDk3Y2JkNjc5MDAiLCJ1c2VySWQiOiI4Njc4NjgxNDcifQ=="/>
	<style type="text/css">
		@page { size: 21cm 29.7cm; margin-left: 3.18cm; margin-right: 3.18cm; margin-top: 2.54cm; margin-bottom: 2.54cm }
		p { line-height: 115%; text-align: justify; orphans: 0; widows: 0; margin-bottom: 0.25cm; direction: ltr; background: transparent }
		p.western { font-family: "Calibri", serif; font-size: 10pt; so-language: en-US }
		p.cjk { font-size: 10pt; so-language: zh-CN; font-family: "宋体" }
		p.ctl { font-family: ; font-size: 12pt; so-language: ar-SA }
		h6 { text-align: left; orphans: 0; widows: 0; margin-top: 0.49cm; margin-bottom: 0.49cm; direction: ltr; background: transparent }
		h6.western { font-family: "宋体", serif; font-weight: bold; font-size: 7pt; so-language: en-US }
		h6.cjk { font-size: 7pt; so-language: zh-CN; font-weight: bold; font-family: "宋体" }
		h6.ctl { font-family: "宋体"; font-size: 7pt; so-language: ar-SA; font-weight: bold }
	</style>
</head>
<body lang="zh-CN" link="#000080" vlink="#800000" dir="ltr"><p class="cjk" style="margin-bottom: 0cm; line-height: 100%">
基本思想</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><font face="Calibri, serif"><span lang="en-US">SJF</span></font>算法是以作业的长度来计算优先级，作业越短，其优先级越高。作业的长短是作业所要求的运行时间来衡量的。</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">算法性能评价</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">面向用户</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">周转时间</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">从作业被提交给系统开始，到作业完成为止的这段时间间隔（作业在后备队列上等待时间、进程在就绪队列上等待时间、进程在<font face="Calibri, serif"><span lang="en-US">cpu</span></font>上执行时间、进程阻塞时间）</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"> <font face="Calibri, serif"><span lang="en-US">1.
</span></font>周转时间<font face="Calibri, serif"><span lang="en-US">=</span></font>完成时间<font face="Calibri, serif"><span lang="en-US">-</span></font>到达时间</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"> <font face="Calibri, serif"><span lang="en-US">2.
</span></font>平均周转时间：周转时间<font face="Calibri, serif"><span lang="en-US">/</span></font>进程数
</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"> <font face="Calibri, serif"><span lang="en-US">3.
</span></font>带权周转时间：周转时间<font face="Calibri, serif"><span lang="en-US">/</span></font>服务时间</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"> <font face="Calibri, serif"><span lang="en-US">4.
</span></font>平均带权周转时间：带权周转时间<font face="Calibri, serif"><span lang="en-US">/</span></font>进程数</p>
<h6 class="cjk" style="margin-top: 0.42cm; margin-bottom: 0.14cm; orphans: 2; widows: 2; border: none; padding: 0cm; line-height: 0.42cm; page-break-inside: auto; background: #ffffff; page-break-after: auto">
<span style="display: inline-block; border: none; padding: 0cm"><span style="font-variant: normal"><font color="#4f4f4f"><span style="letter-spacing: normal"><span style="background: #ffffff"><font face="微软雅黑"><font size="1" style="font-size: 8pt"><span style="font-style: normal"><b>响应时间</b></span></font></font></span></span></font></span></span></h6>
<p align="left" style="margin-bottom: 0.28cm; line-height: 0.46cm; orphans: 2; widows: 2; border: none; padding: 0cm; page-break-inside: auto; background: #ffffff; page-break-after: auto">
<span style="display: inline-block; border: none; padding: 0cm"><font size="3" style="font-size: 12pt"><span style="font-variant: normal"><font color="#4d4d4d"><span style="letter-spacing: normal"><span style="background: #ffffff"><font face="Arial"><font size="1" style="font-size: 8pt"><span style="font-style: normal">从用户通过键盘提交一个请求开始，到系统首次产生响应为止的时间，包括键盘输入时间、信息处理时间和信息回送时间。</span></font></font></span></span></font></span></font></span></p>
<h6 class="cjk" style="margin-top: 0.42cm; margin-bottom: 0.14cm; orphans: 2; widows: 2; border: none; padding: 0cm; line-height: 0.42cm; page-break-inside: auto; background: #ffffff; page-break-after: auto">
<span style="display: inline-block; border: none; padding: 0cm"><span style="font-variant: normal"><font color="#4f4f4f"><span style="letter-spacing: normal"><span style="background: #ffffff"><font face="微软雅黑"><font size="1" style="font-size: 8pt"><span style="font-style: normal"><b>截止时间</b></span></font></font></span></span></font></span></span></h6>
<p align="left" style="margin-bottom: 0.28cm; line-height: 0.46cm; orphans: 2; widows: 2; border: none; padding: 0cm; page-break-inside: auto; background: #ffffff; page-break-after: auto">
<span style="display: inline-block; border: none; padding: 0cm"><font size="3" style="font-size: 12pt"><span style="font-variant: normal"><font color="#4d4d4d"><span style="letter-spacing: normal"><span style="background: #ffffff"><font face="Arial"><font size="1" style="font-size: 8pt"><span style="font-style: normal">某任务必须开始执行的时间（开始截止时间）和执行完成时间（完成截止时间）</span></font></font></span></span></font></span></font></span></p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">以例题来了解</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><img src="%E7%9F%AD%E4%BD%9C%E4%B8%9A%E4%BC%98%E5%85%88%E7%AE%97%E6%B3%95_html_67af1262.png" name="图片 1" align="bottom" width="554" height="151" border="0"/>
</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">系统有如下进程，计算平均周转时间和平均带权周转时间</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">非抢占式调度</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">非抢占式调度<font face="Calibri, serif"><span lang="en-US">(Non-preemptiveMode)</span></font>进程一旦获得处理机，只有在该进程任务完成或因某事件而阻塞时，才让出处理机，决不允许某进程抢占已经分配出去的处理机。</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">方法</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">找出最先到达的进程（该进程的完成时间<font face="Calibri, serif"><span lang="en-US">=</span></font>到达时间<font face="Calibri, serif"><span lang="en-US">+</span></font>服务时间）；</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">根据上一进程的完成时间，找到在这个完成时间内所有到达的进程，并找到这些进程中服务时间最短的那个，然后计算它的完成时间（该进程的完成时间<font face="Calibri, serif"><span lang="en-US">=</span></font>上一进程的完成时间<font face="Calibri, serif"><span lang="en-US">+</span></font>该进程服务时间）；</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">重复<font face="Calibri, serif"><span lang="en-US">2</span></font>直至完成所有进程的计算。</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">过程（<font face="Calibri, serif"><span lang="en-US">A-B-D-C)</span></font></p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><img src="%E7%9F%AD%E4%BD%9C%E4%B8%9A%E4%BC%98%E5%85%88%E7%AE%97%E6%B3%95_html_28536fe7.png" name="图片 2" align="bottom" width="554" height="213" border="0"/>
</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">甘特图</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><img src="%E7%9F%AD%E4%BD%9C%E4%B8%9A%E4%BC%98%E5%85%88%E7%AE%97%E6%B3%95_html_57e058bb.png" name="图片 3" align="bottom" width="489" height="384" border="0"/>
</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">平均周转时间：（<font face="Calibri, serif"><span lang="en-US">1+100+99+200</span></font>）<font face="Calibri, serif"><span lang="en-US">/4=100</span></font></p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">平均带权周转时间：（<font face="Calibri, serif"><span lang="en-US">1+1+99+2</span></font>）<font face="Calibri, serif"><span lang="en-US">/4
=25.75</span></font></p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">抢占式调度</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">抢占式调度<font face="Calibri, serif"><span lang="en-US">(PreemptiveMode)</span></font>允许调度程序根据某种原则，暂停某个占用处理机的进程，抢占已经分配出去的处理机。抢占的原则有优先权原则、短作业优先原则和时间片原则。</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">方法</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">找出最先到达的进程（该进程的完成时间<font face="Calibri, serif"><span lang="en-US">=</span></font>到达时间<font face="Calibri, serif"><span lang="en-US">+</span></font>服务时间）</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">根据上一进程的完成时间，找到在这个完成时间内所有到达的进程，并找到这些进程中服务时间最短的那个，在进程运行中，有新到达的进程时，会比较两者的服务时间（该进程剩余的服务时间与新进程的服务时间进行比较，若小则继续运行，若大则暂停进程，新进程运行。）</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">重复<font face="Calibri, serif"><span lang="en-US">2</span></font>直至完成所有进程的计算。</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">过程</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">甘特图（<font face="Calibri, serif"><span lang="en-US">A-B-D-C</span></font>）</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><img src="%E7%9F%AD%E4%BD%9C%E4%B8%9A%E4%BC%98%E5%85%88%E7%AE%97%E6%B3%95_html_aa00d0ad.png" name="图片 4" align="bottom" width="511" height="396" border="0"/>
</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">平均周转时间：（<font face="Calibri, serif"><span lang="en-US">1+101+1+200</span></font>）<font face="Calibri, serif"><span lang="en-US">/4=75.75</span></font></p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">平均带权周转时间：（<font face="Calibri, serif"><span lang="en-US">1+1+99+2</span></font>）<font face="Calibri, serif"><span lang="en-US">/4
=1.25</span></font></p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%">结论</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><font face="Calibri, serif"><span lang="en-US">SJF</span></font>特点是降低了系统平均周转时间。</p>
<p class="cjk" style="margin-bottom: 0cm; line-height: 100%"><a name="_GoBack"></a>
但对长作业不利，长作业有可能长时间得不到调度。</p>
</body>
</html>